//获取应用实例
const app = getApp();
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    uid: "",
    Seaid: '',
    otype: '',
    pageIndex: 1,
    // 上拉加载
    onBottomData: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var uid = wx.getStorageSync('uid');
    var userType = this.data.userType;
    userType = wx.getStorageSync('userType');
    this.setData({
      uid: uid,
      userType: userType,
      Seaid: options.Seaid,
    })
    // console.log(options);
    this.DeveloperGetClaimBusiness();
  },

  // 开发人员查看已认领的公海客户
  DeveloperGetClaimBusiness: function () {
    var that = this;
    var uid = this.data.uid;
    var pageIndex = this.data.pageIndex;
    var otype = this.data.otype;
    var onBottomData = this.data.onBottomData;
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=DeveloperGetClaimBusiness&UID=" + uid + "&PageIndex=" + pageIndex + "&PageSize=" + 10 + "&OType=" + 2),
      success: function (res) {
        var json = JSON.parse(baseJs.decryUrl(res.data)).ResultData;
        // var json = JSON.parse(baseJs.decryUrl(res.data));
        console.log(json);
        for (var i = 0; i < json.length; i++) {
          onBottomData.push(json[i])
        }
        that.setData({
          onBottomData: onBottomData,
        })

        // if (json.ResultFlag == 1) {
        //   Seaid = wx.getStorageSync('Seaid');
        // }
        if (json.length == 10) {
          that.setData({
            state: 'loadMore',
          })
        } else if (json.length == 0 && pageIndex == 1) {
          that.setData({
            state: 'noData',
          })
        } else if (json.length < 10) {
          that.setData({
            state: 'noMore',
          })
        } else if (json.length == 0 && pageIndex > 1) {
          that.setData({
            state: 'noMore',
          })
        }


      }
    })
  },


  
})